app.service("userService", ["$http", function ($http) {

    this.findById = function (id) {
        return $.get(utils.url("/user/get/{0}", id));
    };
    this.findAllSites = function (id) {
        return $.get(utils.url("/operationSite/findAll"));
    };
    this.findAllProjects = function (id) {
        return $.get(utils.url("/project/findAll"));
    };

    this.query = function (query) {
        return $.get(utils.url("/user/query", id));
    };

    this.getUserName = function () {
        return $.get(utils.url("/user/getUserName"));
    };

    this.delete = function (model) {
        return $.ajax(utils.url("/user/delete"), {
            type: 'POST',
            data: JSON.stringify(model),
            contentType: 'application/json',
            dataType: 'json'
        });
    };

    this.active = function (model) {
        return $.ajax(utils.url("/user/active"), {
            type: 'POST',
            data: JSON.stringify(model),
            contentType: 'application/json',
            dataType: 'json'
        });
    };

    this.inActive = function (model) {
        return $.ajax(utils.url("/user/inActive"), {
            type: 'POST',
            data: JSON.stringify(model),
            contentType: 'application/json',
            dataType: 'json'
        });
    };

    this.create = function (model) {
        return $.ajax(utils.url("/user/create"), {
            type: 'POST',
            data: JSON.stringify(model),
            contentType: 'application/json',
            dataType: 'json'
        });
    };

    this.modify = function (model) {
        return $.ajax(utils.url("/user/update"), {
            type: 'POST',
            data: JSON.stringify(model),
            contentType: 'application/json',
            dataType: 'json'
        });
    };

    this.modifypw = function (model) {
        return $.ajax(utils.url("/user/modifyPassword"), {
            type: 'POST',
            data: JSON.stringify(model),
            contentType: 'application/json',
            dataType: 'json'
        });
    };

    this.modifypwBatch = function (model) {
        return $.ajax(utils.url("/user/modifyPasswordBatch"), {
            type: 'POST',
            data: JSON.stringify(model),
            contentType: 'application/json',
            dataType: 'json'
        });
    };

    this.findSiteByOrgId = function (orgId) {
        return $.ajax(utils.url("/operationSite/findByOrgId"), {
            type: 'POST',
            data: orgId,
            contentType: 'application/json',
            dataType: 'json'
        });
    };

    this.findProjectByOrgId = function (orgId) {
        return $.ajax(utils.url("/project/findByOrgId"), {
            type: 'POST',
            data: orgId,
            contentType: 'application/json',
            dataType: 'json'
        });
    };
}]);